import {
  q as i,
  p as oe,
  ap as fe,
  X as M,
  f as ce,
  H as pe,
  av as O,
  aw as me,
  k as t,
  l,
  m as a,
  ax as R,
  as as f,
  az as ge,
  at as w,
  ay as he
} from "./index-30f27935.js";
import { d as ye, c as H } from "./order-e84dc57e.js";
function g(m) {
  return (
    typeof m == "function" ||
    (Object.prototype.toString.call(m) === "[object Object]" && !he(m))
  );
}
function De(m) {
  const b = i([]),
    _ = i([]),
    I = i([]),
    A = i([]),
    C = i({}),
    p = i(!0);
  i({}), oe();
  const h = i(1),
    S = i(),
    N = i(),
    v = i(""),
    x = i(""),
    y = i(10),
    c = i([]),
    V = i(),
    L = i("nohide"),
    D = i(),
    F = i(""),
    Y = i(""),
    j = fe("reload"),
    E = M({
      pageSize: 10,
      currentPage: 1,
      pageSizes: [10, 20, 30],
      total: 0,
      align: "right",
      background: !0,
      small: !1
    }),
    T = M({
      text: "正在加载第一页...",
      viewBox: "-10, -10, 50, 50",
      spinner: `
        <path class="path" d="
          M 30 15
          L 28 17
          M 25.61 25.61
          A 15 15, 0, 0, 1, 15 30
          A 15 15, 0, 1, 1, 27.99 7.5
          L 15 15
        " style="stroke-width: 4px; fill: rgba(0, 0, 0, 0)"/>
      `
    }),
    U = [
      {
        type: "selection",
        width: 55,
        align: "left",
        hide: ({ checkList: e }) => !e.includes("勾选列")
      },
      {
        label: "序号",
        type: "index",
        width: 70,
        hide: ({ checkList: e }) => !e.includes("序号列")
      },
      {
        label: "ID",
        prop: "order_id",
        minWidth: 80,
        formatter: ({ order_id: e }) => `1${e}`
      },
      {
        label: "用户ID",
        prop: "user_id",
        minWidth: 80,
        formatter: ({ user_id: e }) => `1${e}`
      },
      { label: "姓名", prop: "user_name", minWidth: 130 },
      { label: "手机号", prop: "user_phone", minWidth: 120 },
      {
        label: "地址",
        prop: "address",
        align: "left",
        minWidth: 600,
        hide: () => L.value != "hideAddress",
        formatter: ({ address: e, track_code: u }) =>
          t("div", { style: "word-break: break-all;word-wrap: break-word;" }, [
            t("div", null, [e]),
            t("div", null, [
              u
                ? t(
                    l("el-tag"),
                    { class: "mx-1", type: "success", effect: "light" },
                    g(u) ? u : { default: () => [u] }
                  )
                : ""
            ])
          ])
      },
      {
        label: "商品名称",
        prop: "wares_name",
        minWidth: 250,
        formatter: ({
          wares_name: e,
          store_name: u,
          store_code: n,
          notes: d,
          activity: o,
          remarks: s,
          size: r
        }) =>
          t("div", null, [
            t("div", null, [e]),
            u
              ? t(
                  l("el-tag"),
                  { class: "mx-1", type: "success", effect: "light" },
                  g(u) ? u : { default: () => [u] }
                )
              : "",
            n
              ? t(
                  l("el-tag"),
                  { class: "mx-1", type: "success", effect: "light" },
                  { default: () => [a("门店码:"), n] }
                )
              : "",
            t("div", null, [
              d
                ? t(
                    l("el-tag"),
                    { class: "mx-1", type: "success", effect: "light" },
                    g(d) ? d : { default: () => [d] }
                  )
                : ""
            ]),
            t("div", null, [
              o == 1
                ? t(
                    l("el-tag"),
                    { class: "mx-1", type: "success", effect: "light" },
                    { default: () => [a("已赠送")] }
                  )
                : ""
            ]),
            t("div", null, [
              s
                ? t(
                    l("el-tag"),
                    { class: "mx-1", type: "success", effect: "light" },
                    g(s) ? s : { default: () => [s] }
                  )
                : ""
            ]),
            t("div", null, [
              r
                ? t(
                    l("el-tag"),
                    { class: "mx-1", type: "success", effect: "light" },
                    g(r) ? r : { default: () => [r] }
                  )
                : ""
            ])
          ])
      },
      { label: "产品金额", prop: "wares_price", minWidth: 100 },
      {
        label: "支付金额",
        prop: "pay_price",
        minWidth: 100,
        formatter: ({ pay_price: e }) =>
          t(
            "div",
            { style: "color:#59AB74;font-weight: bold;font-size:16px;" },
            [e]
          )
      },
      { label: "积分折扣", prop: "hock_price", minWidth: 80 },
      { label: "折扣支付", prop: "other_price", minWidth: 80 },
      {
        label: "支付方式",
        prop: "pay_type",
        minWidth: 90,
        formatter: ({ pay_type: e }) => {
          if (e == 1) return "积分";
          if (e == 2) return "微信";
          if (e == 3) return "支付宝";
          if (e == 4) return "复消积分";
        }
      },
      {
        label: "内含数量",
        prop: "all_bottle",
        minWidth: 100,
        formatter: ({ all_bottle: e, wares_unit: u }) => e + u
      },
      { label: "购买数量", prop: "wares_num", minWidth: 80 },
      {
        label: "状态",
        prop: "status",
        minWidth: 150,
        formatter: ({ status: e, track_name: u, content: n }) => {
          if (e == 0)
            return t(
              l("el-tag"),
              { class: "mx-1", type: "info", effect: "light" },
              { default: () => [a("待支付")] }
            );
          if (e == 1)
            return t(
              l("el-tag"),
              { class: "mx-1", type: "", effect: "light" },
              { default: () => [a("待发货")] }
            );
          if (e == 2)
            return t(
              l("el-tag"),
              { class: "mx-1", type: "", effect: "light" },
              { default: () => [a("待自提")] }
            );
          if (e == 7)
            return t(
              l("el-tag"),
              { class: "mx-1", type: "danger", effect: "light" },
              { default: () => [a("在线支付积分不足")] }
            );
          if (e == 8)
            return t(
              l("el-tag"),
              { class: "mx-1", type: "danger", effect: "light" },
              { default: () => [a("奖励发放中")] }
            );
          if (e == 9)
            return t(
              l("el-tag"),
              { class: "mx-1", type: "danger", effect: "light" },
              { default: () => [a("待发放奖励")] }
            );
          if (e == 5)
            return t(
              l("el-tag"),
              { class: "mx-1", type: "danger", effect: "light" },
              { default: () => [a("已退单")] }
            );
          if (e == 3 && u != "自提")
            return t("div", null, [
              " ",
              t(
                l("el-tag"),
                { class: "mx-1", type: "success", effect: "light" },
                { default: () => [a("已快递")] }
              ),
              t("br", null, null),
              t(
                l("el-tag"),
                { class: "mx-1", type: "success", effect: "light" },
                { default: () => [n || "暂无信息"] }
              )
            ]);
          if (e == 3 && u == "自提")
            return t("div", null, [
              " ",
              t(
                l("el-tag"),
                { class: "mx-1", type: "success", effect: "light" },
                { default: () => [a("已自提")] }
              ),
              t("br", null, null),
              t(
                l("el-tag"),
                { class: "mx-1", type: "success", effect: "light" },
                { default: () => [n || "暂无信息"] }
              )
            ]);
        }
      },
      {
        label: "下单时间",
        minWidth: 180,
        prop: "add_time",
        formatter: ({ add_time: e }) => R(e * 1e3).format("YYYY-MM-DD HH:mm:ss")
      },
      { label: "操作", fixed: "right", width: 280, slot: "operation" }
    ],
    k = [
      {
        type: "selection",
        width: 55,
        align: "left",
        hide: ({ checkList: e }) => !e.includes("勾选列")
      },
      {
        label: "序号",
        type: "index",
        width: 70,
        hide: ({ checkList: e }) => !e.includes("序号列")
      },
      { label: "ID", prop: "id", minWidth: 80 },
      { label: "订单ID", prop: "order_id", minWidth: 80 },
      { label: "用户名", prop: "user_name", minWidth: 150 },
      {
        label: "身份",
        prop: "user_place",
        minWidth: 100,
        formatter: ({ user_place: e }) => {
          if (e == 0)
            return t(
              l("el-tag"),
              { class: "mx-1", type: "success", effect: "light" },
              { default: () => [a("暂无")] }
            );
          if (e == 1)
            return t(
              l("el-tag"),
              { class: "mx-1", type: "success", effect: "light" },
              { default: () => [a("一星合伙人")] }
            );
          if (e == 2)
            return t(
              l("el-tag"),
              { class: "mx-1", type: "success", effect: "light" },
              { default: () => [a("二星合伙人")] }
            );
          if (e == 3)
            return t(
              l("el-tag"),
              { class: "mx-1", type: "success", effect: "light" },
              { default: () => [a("三星合伙人")] }
            );
          if (e == 4)
            return t(
              l("el-tag"),
              { class: "mx-1", type: "success", effect: "light" },
              { default: () => [a("四星合伙人")] }
            );
          if (e == 5)
            return t(
              l("el-tag"),
              { class: "mx-1", type: "success", effect: "light" },
              { default: () => [a("五星合伙人")] }
            );
          if (e == 6)
            return t(
              l("el-tag"),
              { class: "mx-1", type: "success", effect: "light" },
              { default: () => [a("一星联创")] }
            );
          if (e == 7)
            return t(
              l("el-tag"),
              { class: "mx-1", type: "success", effect: "light" },
              { default: () => [a("二星联创")] }
            );
          if (e == 8)
            return t(
              l("el-tag"),
              { class: "mx-1", type: "success", effect: "light" },
              { default: () => [a("三星联创")] }
            );
          if (e == 9)
            return t(
              l("el-tag"),
              { class: "mx-1", type: "success", effect: "light" },
              { default: () => [a("四星联创")] }
            );
          if (e == 10)
            return t(
              l("el-tag"),
              { class: "mx-1", type: "success", effect: "light" },
              { default: () => [a("一星董事")] }
            );
          if (e == 11)
            return t(
              l("el-tag"),
              { class: "mx-1", type: "success", effect: "light" },
              { default: () => [a("二星董事")] }
            );
          if (e == 12)
            return t(
              l("el-tag"),
              { class: "mx-1", type: "success", effect: "light" },
              { default: () => [a("三星董事")] }
            );
        }
      },
      { label: "手机号", prop: "user_phone", minWidth: 120 },
      {
        label: "积分",
        prop: "income",
        minWidth: 100,
        formatter: ({ income: e, money: u }) => e || u
      },
      {
        label: "状态",
        prop: "status",
        minWidth: 100,
        formatter: ({ status: e }) => {
          if (e == 1)
            return t(
              l("el-tag"),
              { class: "mx-1", type: "success", effect: "light" },
              { default: () => [a("已发放")] }
            );
          if (e == 2)
            return t(
              l("el-tag"),
              { class: "mx-1", type: "info", effect: "light" },
              { default: () => [a("未发放")] }
            );
        }
      },
      { label: "类型", prop: "type_name", minWidth: 100 },
      { label: "来源用户", prop: "source_name", minWidth: 150 },
      { label: "来源用户手机号", prop: "source_phone", minWidth: 120 }
    ],
    $ = [
      {
        type: "selection",
        width: 55,
        align: "left",
        hide: ({ checkList: e }) => !e.includes("勾选列")
      },
      {
        label: "序号",
        type: "index",
        width: 70,
        hide: ({ checkList: e }) => !e.includes("序号列")
      },
      { label: "用户ID", prop: "user_id", minWidth: 80 },
      { label: "订单ID", prop: "order_id", minWidth: 80 },
      { label: "收件人手机号", prop: "phone", minWidth: 120 },
      { label: "收件人姓名", prop: "name", minWidth: 120 },
      { label: "收件人地址", prop: "address", minWidth: 150 },
      { label: "商品信息", prop: "wares", minWidth: 150 },
      { label: "订单编号", prop: "order_code", minWidth: 150 },
      { label: "支付金额", prop: "pay_price", minWidth: 100 },
      {
        label: "状态",
        prop: "status",
        minWidth: 100,
        formatter: ({ status: e, track_name: u }) => {
          if (e == 1)
            return t(
              l("el-tag"),
              { class: "mx-1", type: "danger", effect: "light" },
              { default: () => [a("待发货")] }
            );
          if (e == 2)
            return t(
              l("el-tag"),
              { class: "mx-1", type: "danger", effect: "light" },
              { default: () => [a("待自提")] }
            );
          if (e == 7)
            return t(
              l("el-tag"),
              { class: "mx-1", type: "danger", effect: "light" },
              { default: () => [a("在线支付积分不足")] }
            );
          if (e == 8)
            return t(
              l("el-tag"),
              { class: "mx-1", type: "danger", effect: "light" },
              { default: () => [a("奖励发放中")] }
            );
          if (e == 9)
            return t(
              l("el-tag"),
              { class: "mx-1", type: "danger", effect: "light" },
              { default: () => [a("待发放奖励")] }
            );
          if (e == 5)
            return t(
              l("el-tag"),
              { class: "mx-1", type: "danger", effect: "light" },
              { default: () => [a("已退单")] }
            );
          if (e == 3 && u != "自提")
            return t(
              l("el-tag"),
              { class: "mx-1", type: "success", effect: "light" },
              { default: () => [a("已快递")] }
            );
          if (e == 3 && u == "自提")
            return t(
              l("el-tag"),
              { class: "mx-1", type: "success", effect: "light" },
              { default: () => [a("已自提")] }
            );
        }
      },
      { label: "内含几瓶", prop: "all_bottle", minWidth: 100 },
      { label: "单位", prop: "wares_unit", minWidth: 100 },
      { label: "门店码", prop: "store_code", minWidth: 100 },
      { label: "门店名称", prop: "store_name", minWidth: 100 },
      {
        label: "下单时间",
        minWidth: 180,
        prop: "add_time",
        formatter: ({ add_time: e }) => R(e * 1e3).format("YYYY-MM-DD HH:mm:ss")
      },
      { label: "衣服规格", prop: "size", minWidth: 100 },
      { label: "订单备注", prop: "remarks", minWidth: 100 },
      { label: "备注", prop: "notes", minWidth: 100 },
      { label: "操作", fixed: "right", width: 250, slot: "operation" }
    ],
    q = ce(() => [
      "!h-[20px]",
      "reset-margin",
      "!text-gray-500",
      "dark:!text-white",
      "dark:hover:!text-primary"
    ]);
  async function X(e) {
    const u = { order_id: e.order_id },
      n = JSON.stringify(u),
      o = { value: f.enc.Base64.stringify(f.enc.Utf8.parse(n)) },
      s = await ye(o);
    s.code == 200 &&
      ((_.value = s.data.income),
      (I.value = s.data.dispel),
      (A.value = s.data.freeze),
      (C.value = s.data.indent));
  }
  async function G(e) {
    ge(e);
  }
  async function K(e) {
    const u = { id: e.id },
      n = JSON.stringify(u),
      o = { value: f.enc.Base64.stringify(f.enc.Utf8.parse(n)) },
      s = await questionDelete(o);
    s.code == 200
      ? (w("删除成功", { type: "success" }), j())
      : w(s.msg, { type: "error" });
  }
  function Q() {}
  function Z(e) {
    (y.value = e), W(void 0, e);
  }
  function P(e) {
    (h.value = e), W(e, void 0);
  }
  function ee(e) {}
  function te(e) {
    (T.text = `正在加载第${e}页...`),
      (p.value = !0),
      O(600).then(() => {
        p.value = !1;
      });
  }
  async function le(e, u, n = [], d, o, s, r, B, z) {
    (c.value = []),
      n.map(ne => {
        const re = ne,
          de = new Date(re);
        c.value.push(
          de.toLocaleDateString("zh-CN", {
            year: "numeric",
            month: "2-digit",
            day: "2-digit"
          })
        );
      }),
      (p.value = !0),
      (D.value = e),
      (S.value = d),
      (N.value = o),
      (V.value = u),
      (v.value = s),
      (x.value = r),
      (F.value = B),
      (Y.value = z);
    const ue = {
        page: h.value,
        pagesize: y.value,
        status: e,
        user_phone: isNaN(u) ? void 0 : u,
        user_id: isNaN(d) ? void 0 : d,
        user_name: isNaN(u) ? u : void 0,
        order_code: s || void 0,
        name_phone: r || void 0,
        wares_unit: B == "no" ? void 0 : B,
        all_bottle: z || void 0,
        start: c.value[0],
        end: c.value[1],
        store_code: o,
        action: "add_time"
      },
      se = JSON.stringify(ue),
      ie = { value: f.enc.Base64.stringify(f.enc.Utf8.parse(se)) },
      { data: J } = await H(ie);
    (b.value = J.indent.data),
      (E.total = J.indent.total),
      setTimeout(() => {
        p.value = !1;
      }, 500);
  }
  async function W(e = h.value, u = y.value) {
    const n = {
        page: e,
        pagesize: u,
        status: D.value,
        start: c.value[0],
        end: c.value[1],
        user_phone: V.value,
        user_id: S.value,
        order_code: v.value ? v.value : void 0,
        name_phone: x.value ? x.value : void 0,
        wares_unit: F.value == "no" ? void 0 : F.value,
        all_bottle: Y.value || void 0,
        store_code: N.value,
        action: "add_time"
      },
      d = JSON.stringify(n),
      s = { value: f.enc.Base64.stringify(f.enc.Utf8.parse(d)) },
      r = await H(s);
    r.code === 200
      ? ((b.value = r.data.indent.data),
        (E.total = r.data.indent.total),
        setTimeout(() => {
          p.value = !1;
        }, 500))
      : w(r.msg, { type: "error" });
  }
  const ae = e => {
    e && (e.resetFields(), location.reload());
  };
  return (
    pe(() => {
      O().then(() => {
        const { setWatermark: e } = me(m.value.getTableDoms().tableWrapper);
        e("后台项目", {
          font: "16px Microsoft YaHei",
          globalAlpha: 0.8,
          forever: !0,
          width: 252,
          height: 80
        });
      }),
        W();
    }),
    {
      loading: p,
      columns: U,
      dataList: b,
      userColumns: k,
      pagination: E,
      buttonClass: q,
      userDatilList: _,
      userDatilListDisple: I,
      userDatilListFreeze: A,
      orderInfo: C,
      columnsTable: $,
      count: h,
      hideVal: L,
      pageCount: y,
      formattedDate: c,
      typeCount: D,
      handleLookUserDatil: X,
      onSearch: le,
      resetForm: ae,
      handleaddUser: Q,
      handleUpdate: G,
      handleDelete: K,
      handleSizeChange: Z,
      handleCurrentChange: P,
      handleSelectionChange: ee,
      onCurrentChange: te
    }
  );
}
export { De as useRole };
